import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
df = pd.read_excel('餐厅订单信息.xlsx')
plt.rcParams['font.sans-serif'] = 'SimHei'

plt.figure()
width = 0.15
i = 0
x = np.arange(3)
groups = df.groupby('店铺名')
shop_name = []
for group in groups:
    shop_name.append(group[0])
    df_temp = pd.DataFrame(group[1])
    df_temp = df_temp.groupby('会员星级').agg('sum', numeric_only=True)
    height = df_temp['消费金额']
    plt.bar(x + width * i, height, width)
    i += 1
plt.legend(shop_name)
plt.xlabel('会员星级')
plt.ylabel('消费金额（元）')
plt.xticks(range(3), df_temp.index)
plt.title('各分店不同星级会员消费金额柱状图')

plt.figure()
x = df['价格']
plt.xlabel('菜品价格（元）')
plt.ylabel('菜品数量')
plt.title('菜品数量分布直方图')
plt.hist(x, bins=8, color=(0.894, 0, 0.498), edgecolor='k')

plt.figure()
x = df['价格']
y = df['消费金额']
plt.scatter(x, y)
plt.title('菜品价格与消费金额相关性散点图')
plt.show()